/*
	利用双向链表实现了队列的顺序保存。即在头节点处取出，在尾节点处插入。貌似单链表就可以实现啊。是栈无法实现顺序顺序存储在单链表里。
*/
#include <stdio.h>
#include <stdlib.h>
typedef struct queueNode* link;
typedef struct queueNode{
	int data;	
	struct queueNode *prev, *next;
}queueNode;
link head, tail;
void queueInitial(){
	link temp = (link)malloc(sizeof(queueNode));
	temp->prev = temp;
	temp->next = temp;
	head = tail = temp;	
}
void queuePush(int in){
	link temp = (link)malloc(sizeof(queueNode));
	temp->data = in;
	temp->next = tail->next;	
	temp->prev = tail;
	tail->next->prev = temp;
	tail->next = temp; 
	tail = temp;
}
void queuePop(){
	int re = head->next->data;
	link h = head->next;
	h->next->prev = h->prev; 
	h->prev->next= h->next;
	printf("%d\n", re);
}
int main(){
	queueInitial();
	queuePush(10);
	queuePush(110);
	queuePush(1110);
	queuePush(1110);
	queuePop();	
	queuePop();	
	queuePop();	
	queuePop();	
	queuePop();	
	queuePop();	
}
